/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package slcu.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import slcu.model.CategoriaDisciplina;
import slcu.model.CategoriaDisciplinaModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the CategoriaDisciplina service. Represents a row in the &quot;SLCU_CategoriaDisciplinas&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link slcu.model.CategoriaDisciplinaModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CategoriaDisciplinaImpl}.
 * </p>
 *
 * @author tito
 * @see CategoriaDisciplinaImpl
 * @see slcu.model.CategoriaDisciplina
 * @see slcu.model.CategoriaDisciplinaModel
 * @generated
 */
public class CategoriaDisciplinaModelImpl extends BaseModelImpl<CategoriaDisciplina>
	implements CategoriaDisciplinaModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a CategoriaDisciplinas model instance should use the {@link slcu.model.CategoriaDisciplina} interface instead.
	 */
	public static final String TABLE_NAME = "SLCU_CategoriaDisciplinas";
	public static final Object[][] TABLE_COLUMNS = {
			{ "categoriaId", Types.BIGINT },
			{ "disciplinaId", Types.BIGINT },
			{ "nombre", Types.VARCHAR },
			{ "edadMinima", Types.BIGINT },
			{ "edadMaxima", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table SLCU_CategoriaDisciplinas (categoriaId LONG not null primary key,disciplinaId LONG,nombre VARCHAR(75) null,edadMinima LONG,edadMaxima LONG)";
	public static final String TABLE_SQL_DROP = "drop table SLCU_CategoriaDisciplinas";
	public static final String ORDER_BY_JPQL = " ORDER BY categoriaDisciplina.nombre ASC";
	public static final String ORDER_BY_SQL = " ORDER BY SLCU_CategoriaDisciplinas.nombre ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.slcu.model.CategoriaDisciplina"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.slcu.model.CategoriaDisciplina"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.slcu.model.CategoriaDisciplina"),
			true);
	public static long DISCIPLINAID_COLUMN_BITMASK = 1L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.slcu.model.CategoriaDisciplina"));

	public CategoriaDisciplinaModelImpl() {
	}

	public long getPrimaryKey() {
		return _categoriaId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCategoriaId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_categoriaId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return CategoriaDisciplina.class;
	}

	public String getModelClassName() {
		return CategoriaDisciplina.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("categoriaId", getCategoriaId());
		attributes.put("disciplinaId", getDisciplinaId());
		attributes.put("nombre", getNombre());
		attributes.put("edadMinima", getEdadMinima());
		attributes.put("edadMaxima", getEdadMaxima());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long categoriaId = (Long)attributes.get("categoriaId");

		if (categoriaId != null) {
			setCategoriaId(categoriaId);
		}

		Long disciplinaId = (Long)attributes.get("disciplinaId");

		if (disciplinaId != null) {
			setDisciplinaId(disciplinaId);
		}

		String nombre = (String)attributes.get("nombre");

		if (nombre != null) {
			setNombre(nombre);
		}

		Long edadMinima = (Long)attributes.get("edadMinima");

		if (edadMinima != null) {
			setEdadMinima(edadMinima);
		}

		Long edadMaxima = (Long)attributes.get("edadMaxima");

		if (edadMaxima != null) {
			setEdadMaxima(edadMaxima);
		}
	}

	public long getCategoriaId() {
		return _categoriaId;
	}

	public void setCategoriaId(long categoriaId) {
		_categoriaId = categoriaId;
	}

	public long getDisciplinaId() {
		return _disciplinaId;
	}

	public void setDisciplinaId(long disciplinaId) {
		_columnBitmask |= DISCIPLINAID_COLUMN_BITMASK;

		if (!_setOriginalDisciplinaId) {
			_setOriginalDisciplinaId = true;

			_originalDisciplinaId = _disciplinaId;
		}

		_disciplinaId = disciplinaId;
	}

	public long getOriginalDisciplinaId() {
		return _originalDisciplinaId;
	}

	public String getNombre() {
		if (_nombre == null) {
			return StringPool.BLANK;
		}
		else {
			return _nombre;
		}
	}

	public void setNombre(String nombre) {
		_columnBitmask = -1L;

		_nombre = nombre;
	}

	public long getEdadMinima() {
		return _edadMinima;
	}

	public void setEdadMinima(long edadMinima) {
		_edadMinima = edadMinima;
	}

	public long getEdadMaxima() {
		return _edadMaxima;
	}

	public void setEdadMaxima(long edadMaxima) {
		_edadMaxima = edadMaxima;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			CategoriaDisciplina.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public CategoriaDisciplina toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (CategoriaDisciplina)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		CategoriaDisciplinaImpl categoriaDisciplinaImpl = new CategoriaDisciplinaImpl();

		categoriaDisciplinaImpl.setCategoriaId(getCategoriaId());
		categoriaDisciplinaImpl.setDisciplinaId(getDisciplinaId());
		categoriaDisciplinaImpl.setNombre(getNombre());
		categoriaDisciplinaImpl.setEdadMinima(getEdadMinima());
		categoriaDisciplinaImpl.setEdadMaxima(getEdadMaxima());

		categoriaDisciplinaImpl.resetOriginalValues();

		return categoriaDisciplinaImpl;
	}

	public int compareTo(CategoriaDisciplina categoriaDisciplina) {
		int value = 0;

		value = getNombre().compareTo(categoriaDisciplina.getNombre());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CategoriaDisciplina categoriaDisciplina = null;

		try {
			categoriaDisciplina = (CategoriaDisciplina)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = categoriaDisciplina.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		CategoriaDisciplinaModelImpl categoriaDisciplinaModelImpl = this;

		categoriaDisciplinaModelImpl._originalDisciplinaId = categoriaDisciplinaModelImpl._disciplinaId;

		categoriaDisciplinaModelImpl._setOriginalDisciplinaId = false;

		categoriaDisciplinaModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<CategoriaDisciplina> toCacheModel() {
		CategoriaDisciplinaCacheModel categoriaDisciplinaCacheModel = new CategoriaDisciplinaCacheModel();

		categoriaDisciplinaCacheModel.categoriaId = getCategoriaId();

		categoriaDisciplinaCacheModel.disciplinaId = getDisciplinaId();

		categoriaDisciplinaCacheModel.nombre = getNombre();

		String nombre = categoriaDisciplinaCacheModel.nombre;

		if ((nombre != null) && (nombre.length() == 0)) {
			categoriaDisciplinaCacheModel.nombre = null;
		}

		categoriaDisciplinaCacheModel.edadMinima = getEdadMinima();

		categoriaDisciplinaCacheModel.edadMaxima = getEdadMaxima();

		return categoriaDisciplinaCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{categoriaId=");
		sb.append(getCategoriaId());
		sb.append(", disciplinaId=");
		sb.append(getDisciplinaId());
		sb.append(", nombre=");
		sb.append(getNombre());
		sb.append(", edadMinima=");
		sb.append(getEdadMinima());
		sb.append(", edadMaxima=");
		sb.append(getEdadMaxima());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("slcu.model.CategoriaDisciplina");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>categoriaId</column-name><column-value><![CDATA[");
		sb.append(getCategoriaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>disciplinaId</column-name><column-value><![CDATA[");
		sb.append(getDisciplinaId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>nombre</column-name><column-value><![CDATA[");
		sb.append(getNombre());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>edadMinima</column-name><column-value><![CDATA[");
		sb.append(getEdadMinima());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>edadMaxima</column-name><column-value><![CDATA[");
		sb.append(getEdadMaxima());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = CategoriaDisciplina.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			CategoriaDisciplina.class
		};
	private long _categoriaId;
	private long _disciplinaId;
	private long _originalDisciplinaId;
	private boolean _setOriginalDisciplinaId;
	private String _nombre;
	private long _edadMinima;
	private long _edadMaxima;
	private long _columnBitmask;
	private CategoriaDisciplina _escapedModelProxy;
}